package com.panopset.mocean.swing;

import java.awt.Color;
import java.awt.Graphics2D;

import javax.swing.JFrame;

import com.panopset.compat.Zombie;
import com.panopset.games.mocean.MoceanSprite;
import com.panopset.games.mocean.MoceanSurface;
import com.panopset.sf.FullScreenWindow;

public class MoceanSwing {

    /**
     * @param args
     */
    public static void main(String[] args) {
        new MoceanSwing().go();
    }


    void go() {
        FullScreenWindow fsw = new FullScreenWindow() {
            @Override
            protected void save() {
                super.save();
                Zombie.stop();
            }

            @Override
            public void paintCycle(Graphics2D g) {

                g.setColor(new Color(0x334433));
                g.fillRect(0, 0, getWidth(), getHeight());

                for (MoceanSprite s : getMoceanSurface().getSprites(getWidth(),
                        getHeight())) {

                    g.setColor(new Color(s.getMembraneColorAsInt()));
                    g.fillOval(s.getX0(), s.getY0(), s.getWidth(), s.getHeight());


                    g.setColor(new Color(s.getColorAsInt()));
                    g.fillOval(s.getX0() + 1, s.getY0() + 1, s.getWidth() - 2, s.getHeight() -2 );

                }


            }
        };
        fsw.getFrame().setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        fsw.show();
    }

    private MoceanSurface ms;

    private MoceanSurface getMoceanSurface() {
        if (ms == null) {
            ms = new MoceanSurface();
        }
        return ms;
    }

}
